package pt.ist.meic.pava;

import javassist.CtMethod;



/**
 * 
 * @author Antonio Massingue
 * @author Joao Matos
 * @author Nuno Santos
 * 
 * This class represents a trait method
 * 
 */
public class TraitMethod {
	
	
	/**
	 * The method as a CtMethod object
	 */
	private CtMethod method;
	
	/**
	 * The method s alias
	 */
	private String alias;
	
	/**
	 * The name of the class containing this method
	 */
	private String Class;
	
	/**
	 * Does this method have an alias
	 */
	private boolean hasAlias;
	
	
	/**
	 * The Constructor
	 * 
	 * @param method	The method as a CtMethod Object
	 * @param alias		The alias name
	 * @param Class		The name of the class owner of this method
	 */
	public TraitMethod(CtMethod method, String alias, String Class){
		
		this.method = method;
		
		this.alias = alias;
		
		this.hasAlias = true;
		
		this.Class = Class;
		
	}
	
	/**
	 * The Overloading Constructor; no alias
	 * 
	 * @param method	The method as a CtMethod Object
	 * @param Class		The name of the class owner of this method
	 */
	public TraitMethod(CtMethod method, String Class) {
		
		this.method = method;
		
		this.Class = Class;
		
		this.hasAlias = false;
		
		this.alias = method.getName();
		
	}
	
	
	/**
	 * @return true if this method has alias; false otherwise
	 */
	public boolean hasAlias(){
		
		return this.hasAlias;
		
		
	}
	
	/**
	 * Sets an alias for this method
	 * @param alias
	 */
	public void setAlias(String alias) {
		
		
		this.alias = alias;
		this.hasAlias = true;
		
	}
	
	/**
	 * Sets a CtMethod object for this method
	 * @param mt
	 */
	public void setMethod(CtMethod mt){
		
		this.method = mt;
	}
	
	/**
	 * Gets the CtMethod object for this method
	 * @param mt
	 */
	public CtMethod getMethod(){
		
		return this.method;
	}
	
	/**
	 * Gets the alias referent to this method
	 * @param mt
	 */
	public String getAlias(){
		
		return this.alias;
	}
	
	/**
	 * Gets the name of the class owner of this method
	 * @param mt
	 */
	public String getTraitClass(){
		
		return this.Class;
	}
	
	
	
	
	
	
	
	
	
}
